<!DOCTYPE HTML>
<html>

<head>
    <title> 会员等级</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../../../assets/css/dpl-min.css" rel="stylesheet" type="text/css"/>
    <link href="../../../assets/css/bui-min.css" rel="stylesheet" type="text/css" />
    <link href="../../../assets/css/page-min.css" rel="stylesheet" type="text/css" />
    <link href="../../../assets/css/prettify.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <div class="container">
        <div class="detail-page">
            <div class="span24">
                <h2>会员等级<button type="button" id="add-user-level-btn" class="pull-right button button-default">新增会员等级</button></h2>
                <hr>
            </div>
            <div class="detail-section">
                <div class="row detail-row">
                    <div class="span24">
                        <!-- 表格 start-->
                        <div id="grid"></div>
                        <!-- 表格 end-->
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../../../assets/js/jquery-1.8.1.min.js"></script>
    <script type="text/javascript" src="../../../assets/js/bui-min.js"></script>
    <script type="text/javascript" src="../../../assets/js/config-min.js"></script>
    <script type="text/javascript">
    BUI.use('common/page');
    </script>
    <!-- script start -->
    <script type="text/javascript">
    $("#add-user-level-btn").click(function() {
        top.topManager.openPage({
            id: 'user-add-levelo',
            href: 'templates/user/user-level/user-add-level.html',
            title: '新增会员等级'
        });
    });
    BUI.use(['bui/grid', 'bui/data', 'common/search'], function(Grid, Data, Search) {
        var Grid = Grid,
            Store = Data.Store,
            columns = [{
                title: '会员等级',
                dataIndex: 'a',
                elCls: 'center', //居中
                width: 200
            }, {
                title: '所需订单金额 ',
                elCls: 'center',
                dataIndex: 'b',
                width: 200
            }, {
                title: '操作',
                dataIndex: 'f',
                elCls: 'center',
                width: 200,
                renderer: function(value, obj) {
                    var editStr = Search.createLink({ //链接使用 此方式
                        id: 'edit' + obj.id,
                        title: '编辑等级',
                        text: '[ 编辑 ] ',
                        href: 'templates/user/user-level/user-add-level.html'
                    })

                    return editStr;
                }
            }],
            data = [{
                id: '1222',
                a: 'F2',
                b: '4000',

            }, {
                id: '1222',
                a: 'F2',
                b: '4000',

            }];
        //初始化数据
        var isAddRemote = false,
            editing = new Grid.Plugins.DialogEditing({
                contentId: 'content', //设置隐藏的Dialog内容
                triggerCls: 'btn-edit', //触发显示Dialog的样式

                editor: {
                    title: '编辑商品品牌',
                    width: 600,
                }
            }),
            store = new Store({ //初始化数据
                data: data,
                autoLoad: true, //自动加载数据
                pageSize: 2 // 配置分页数目
            }),
            grid = new Grid.Grid({
                render: '#grid',
                elCls: 'small-bui-grid-table',
                columns: columns,
                loadMask: true, //加载数据时显示屏蔽层
                forceFit: true,

                // 底部工具栏
                bbar: {
                    // pagingBar:表明包含分页栏
                    pagingBar: true
                },
                plugins: [editing], //插件
                store: store
            });

        grid.render();
        //点击操作
        grid.on('itemclick', function(ev) {
            var sender = $(ev.domTarget),
                itemEl = $(ev.element),
                item = ev.item;

            if (sender.hasClass('btn-del')) { //点击删除操作
                delFunction(item, itemEl);

            }
        });
        $("#add-user-level-btn").click(function() {

        });
        //没有多选插件，删除选中的记录
        function delFunction(item, itemEl) {
            BUI.Message.Confirm('确认删除记录？', function() {
                var input = itemEl.find('input'),
                    name = itemEl.attr('name');
                if (name) {
                    form.getField(name).remove();
                }

                store.remove(item);
            }, 'question');
        }
    });
    </script>
    <!-- script end -->

    <body>

</html>
